package cate.game.role.farm.forbidden.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdForbidden;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@OperationSetter(value = GDOperation.FORBIDDEN_CHALLENGE, sub = "type")
@ClientMsg(title = "挑战禁地属性副本 の 请求")
public class ForbiddenChallengeReq implements MsgInput {
    @NoteField(value = "禁地属性类型")
    public int type;
    @NoteField(value = "第几关")
    public int stage;
    @NoteField(value = "扫荡")
    public boolean mop;

    @Override
    public MsgConfig conf() {
        return MsgIdForbidden.FORBIDDEN_CHALLENGE_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        GameResult<Void> r = cc.getRole().getFarm().forbidden.challenge(type, stage, mop, false);
        if (r.ok()) {
            cc.getRole().sendNow(new ForbiddenDataUpdateResp(cc.getRole()));
        } else {
            game.notice.message(cc.getRole(), r, true);
        }
    }
}
